package Lab3;

abstract class Circle {
    private double radius;

    public Circle(double r) {
        radius = r;
    }

    public String toString() {
        return "Circle radius: " + radius + ", area: " + getArea();
    }

    public double getRadius() {
        return radius;
    }

    public double getArea() {
        return radius * radius * Math.PI;
    }
}

class ComparableCircle extends Circle implements Comparable<ComparableCircle> {
    public ComparableCircle(double r) {
        super(r);
    }

    public static ComparableCircle max(ComparableCircle a, ComparableCircle b) {
        return (a.compareTo(b) >= 0) ? a : b;
    }

    @Override
    public int compareTo(ComparableCircle o) {
        if (getRadius() > o.getRadius()) return 1;
        else if (getRadius() == o.getRadius()) return 0;
        return -1;
    }
}

class TestCircle {
    public static void main(String[] args) {
        ComparableCircle a = new ComparableCircle(3);
        ComparableCircle b = new ComparableCircle(5);
        ComparableCircle c = ComparableCircle.max(a,b);
        System.out.println(c);
    }
}